<template>
  <div class="footer">
    <div class="footer-content">
      <div class="link">
        Copyright © 2017－2020 上海耶购电子商务有限公司 版权所有
        <span @click="() => onHrefClick('icp')">沪ICP备17007848号-1</span>
        <span class="msp" @click="() => onHrefClick('telecommunication')">沪B2-20230252</span>
      </div>
      <div class="lisence">
        <span @click="() => onHrefClick('qualica')">互联网药品信息服务资格证（沪）-经营性-2023-0069</span>
        <span @click="() => onHrefClick('certificate')">医疗器械网络交易服务第三方平台备案凭证（沪）网械平台备字[2019]第 00004 号</span>
        <span @click="() => onHrefClick('license')">营业执照</span>
      </div>
      <div class="footerImage">
        <img src="@/assets/images/1.png" @click="() => onIconHrefClick('icp')" />
        <img src="@/assets/images/2.png" @click="() => onIconHrefClick('police')" />
        <img src="@/assets/images/3.png" @click="() => onIconHrefClick('administration')" />
        <img src="@/assets/images/4.png" @click="() => onIconHrefClick('credible')" />
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const onHrefClick = (type) => {
  if (type === 'icp') {
    window.open('https://beian.miit.gov.cn/#/Integrated/recordQuery', '_blank')
  } else if (type === 'telecommunication') {
    let { href } = router.resolve({
      path: `/medicine/tel_license`
    })
    window.open(href, '_blank')
  } else if (type === 'qualica') {
    let { href } = router.resolve({
      path: `/medicine/service_license`
    })
    window.open(href, '_blank')
  } else if (type === 'certificate') {
    let { href } = router.resolve({
      path: `/file_proof`
    })
    window.open(href, '_blank')
  } else if (type === 'license') {
    let { href } = router.resolve({
      path: `/business_license`
    })
    window.open(href, '_blank')
  }
}

const onIconHrefClick = (type) => {
  if (type === 'credible') {
    window.open('https://t.knet.cn/', '_blank')
  } else if (type === 'police') {
    // window.open('https://www.shjbzx.cn/', '_blank')
    window.open('http://cyberpolice.mps.gov.cn/wfjb/html/index.shtml', '_blank')
  } else if (type === 'icp') {
    window.open('https://beian.miit.gov.cn/', '_blank')
  } else if (type === 'administration') {
    window.open('https://scjgj.sh.gov.cn/', '_blank')
  }
}
</script>

<style lang="scss" scoped>
.footer {
  padding: 40px 0;
  background-color: #3e424c;
  border-top: 2px solid var(--color-primary);
  box-sizing: border-box;

  .footer-content {
    width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    span,
    img {
      cursor: pointer;
      margin-left: 10px;
    }

    span:hover {
      color: var(--color-primary);
    }

    .link {
      color: var(--background);
      line-height: 18px;
    }

    .lisence {
      color: #fff;

      span {
        display: inline-block;
        line-height: 18px;
        margin: 10px 15px 0 0;
      }
    }

    .footerImage {
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 20px;
    }
  }
}
</style>
